function MonsterSpecialSelect()
{
  if (Battle.MSpecial == "Attack")
  {
  ActiveMonsterAttack();//Regular attack
  }  
  else if (Battle.MSpecial == "Bite")
  {
  SpecialBite();//A more powerful animal attack
  }  
  else if (Battle.MSpecial == "CureSelf")
  {
  SpecialCureSelf();//A common cure move
  }  
  else if (Battle.MSpecial == "Heal")
  {
  SpecialHeal();//A Ranger attack
  }  
  else if (Battle.MSpecial == "Flap")
  {
  SpecialFlap();//Multi-target attack
  }  
  else if (Battle.MSpecial == "Sting")
  {
  SpecialSting();//Sting attack
  }  
  else if (Battle.MSpecial == "Cold Foam")
  {
  SpecialColdFoam();//Sting attack
  }  
  else if (Battle.MSpecial == "Smack")
  {
  SpecialSmack();//chance for 1/2 hp reduction
  }

  else
  {
  Talk_Window("This is a bug, Please report it.", "blank.png");
  }
}
function SpecialCureSelf()
{
RenderMap();
ShowPersonFight();
Delay(200);
RenderMap();
DrawPlayerStats();
BattleName();
WindowStyle.drawWindow(5, 5, 235, 12);
  if (Battle.Mmp < 5)
  {
  Font.drawText(7, 7, "Cure... Not enough Mp");    
  FlipScreen();
  Delay(1000);
  }
  else
  {
  Font.drawText(7, 7, "Cure");    
  Battle.Mmp = Battle.Mmp - 5;
  ReduceMonsterMp(5);
  Player.attackmiss = "";
  Player.attackdamage = Math.floor((Math.random()/5 + .9)*Battle.Mmag*3);

  if (Player.active == "Monster1")
  { 
    Monster1.hp = Monster1.hp + Player.attackdamage;
    if (Monster1.hp > Monster1.maxhp)
    {
    Monster1.hp = Monster1.maxhp;
    }
    ShowMonster1Damage(Player.attackdamage*(0-1))
  }
  if (Player.active == "Monster2")
  {
    Monster2.hp = Monster2.hp + Player.attackdamage;
    if (Monster2.hp > Monster2.maxhp)
    {
    Monster2.hp = Monster2.maxhp;
    }
    ShowMonster2Damage(Player.attackdamage*(0-1))
  }
  if (Player.active == "Monster3")
  {
    Monster3.hp = Monster3.hp + Player.attackdamage;
    if (Monster3.hp > Monster3.maxhp)
    {
    Monster3.hp = Monster3.maxhp;
    }
    ShowMonster3Damage(Player.attackdamage*(0-1))
  }
  if (Player.active == "Monster4")
  {
    Monster4.hp = Monster4.hp + Player.attackdamage;
    if (Monster4.hp > Monster4.maxhp)
    {
    Monster4.hp = Monster4.maxhp;
    }
    ShowMonster4Damage(Player.attackdamage*(0-1))
  }

//  DrawPlayerStats();
//  BattleName();
//  FlipScreen();
//  Delay(1000);
  
  }
GoToNextMonster()
}

function SpecialBite()
{
SelectPTarget();
RenderMap();
ShowPersonFight();
Delay(200);
RenderMap();
LoadDefStats();
DrawPlayerStats();
BattleName();
WindowStyle.drawWindow(5, 5, 235, 12);
Font.drawText(7, 7, "Bite");    
FlipScreen();
Delay(500);

Battle.math = Math.random()/5 + .9;

  if (Player.attackmiss == "Miss")
  {
    RenderMap();
    TakeOutPlayerHealth();
  }
  else
  {
    RenderMap();
    Player.attackdamage = Math.floor(Battle.Mattack*Battle.Mattack*Battle.math/Player.tempdef);
    TakeOutPlayerHealth();
  }
  if (Player.dead == 3)
  {
  GarbageCollect();
  GameOver();
  }
  else
  {
  Player.attackmiss = "";
  GoToNextMonster();
  }
}

function SpecialHeal()
{
RenderMap();
ShowPersonFight();
Delay(200);
RenderMap();

DrawPlayerStats();
BattleName();
WindowStyle.drawWindow(5, 5, 235, 12);
  if (Battle.Mmp < 5)
  {
  Font.drawText(7, 7, "Heal... Not enough Mp");    
  FlipScreen();
  Delay(1000);
  }
  else
  {
  Font.drawText(7, 7, "Heal");    
  Battle.Mmp = Battle.Mmp - 5;
  ReduceMonsterMp(5);

  Player.attackdamage = Math.floor((Math.random()/5 + .9)*Battle.Mmag*2);

  Battle.Mhp = Battle.Mhp + Player.attackdamage;
    if (Battle.Mhp > Battle.Mmaxhp)
    {
    Battle.Mhp = Battle.Mmaxhp;
    }
  HpFont.drawTextBox (Battle.Mx, Battle.My, 500, 100, 5, Player.attackdamage);
  SetMonsterHp(Battle.Mhp);

  DrawPlayerStats();
  BattleName();
  FlipScreen();
  Delay(1000);
  }
GoToNextMonster();
}
function SpecialFlap()
{
RenderMap();
ShowPersonFight();
Delay(200);
RenderMap();
LoadDefStats();

DrawPlayerStats();
BattleName();
WindowStyle.drawWindow(5, 5, 235, 12);
Font.drawText(7, 7, "Flap");    
FlipScreen();
Delay(500);
RenderMap();

  if (Player.hp > 0)
  {
  Player.attackdamage = Math.floor(Battle.Mattack*Battle.Mattack*(Math.random()/5 + 0.9)/Player.defence*0.75);
  Player.hp = Player.hp - Player.attackdamage;
  Font.drawText(Player.P1x, Player.P1y, Player.attackdamage);
    if (Player.hp < 0)
    {
    Player.hp = 0;
    }
  }
  if (Player2.pres == true)
  {
    if (Player2.hp > 0)
    {
    Player.attackdamage2 = Math.floor(Battle.Mattack*Battle.Mattack*(Math.random()/5 + 0.9)/Player2.defence*0.75);
    Player2.hp = Player2.hp - Player.attackdamage2;
    Font.drawText(Player.P2x, Player.P2y, Player.attackdamage2);
      if (Player2.hp < 0)
      {
      Player2.hp = 0;
      }
    }
  }  
  if (Player3.pres == true)
  {
    if (Player3.hp > 0)
    {
    Player.attackdamage3 = Math.floor(Battle.Mattack*Battle.Mattack*(Math.random()/5 + 0.9)/Player3.defence*0.75);
    Font.drawText(Player.P3x, Player.P3y, Player.attackdamage3);
    Player3.hp = Player3.hp - Player.attackdamage3;
      if (Player3.hp < 0)
      {
      Player3.hp = 0;
      }
    }
  }
  DrawPlayerStats();
  BattleName();
  FlipScreen();
   
  if (Player.hp == 0)
  {
  SetPersonDirection("main character", 9)
  SetPersonFrame("main character", 0)
  }
  if (Player2.hp == 0)
  {
  SetPersonDirection("Player2", 9)
  SetPersonFrame("Player2", 0)
  }
  if (Player3.hp == 0)
  {
  SetPersonDirection("Player3", 9)
  SetPersonFrame("Player3", 0)
  }
Delay(500);
IsPlayerDead();
  if (Player.dead == 3)
  {
  GarbageCollect();
  GameOver();
  }
  else
  {
  GoToNextMonster();
  }
}

function SpecialSting()
{
SelectPTarget();
RenderMap();
ShowPersonFight();
Delay(200);
RenderMap();
LoadDefStats();

DrawPlayerStats();
BattleName();
WindowStyle.drawWindow(5, 5, 235, 12);
Font.drawText(7, 7, "Sting");    
FlipScreen();
Delay(500);

Battle.stingamount = Math.floor(Math.random()*3) + 1;

Battle.math = Math.random()/5 + .9;

  if (Player.attackmiss == "Miss")
  {
    RenderMap();
    TakeOutPlayerHealth();
  }
  else
  {
    RenderMap();
    Player.attackdamage = Math.floor(Battle.Mattack*Battle.Mattack*Battle.math/Player.tempdef);
    TakeOutPlayerHealth();
    if (Player.PTarget == "Player1") 
    {
    Player.stun = Battle.stingamount;
    }
    if (Player.PTarget == "Player2") 
    {
    Player2.stun = Battle.stingamount;
    }
    if (Player.PTarget == "Player3") 
    {
    Player3.stun = Battle.stingamount;
    }
  }
  if (Player.dead == 3)
  {
  GarbageCollect();
  GameOver();
  }
  else
  {
  Player.attackmiss = "";
  GoToNextMonster();
  }
}

function SpecialColdFoam()
{
SelectPTarget();
RenderMap();
ShowPersonFight();
Delay(200);
RenderMap();
LoadDefStats();

DrawPlayerStats();
BattleName();
WindowStyle.drawWindow(5, 5, 235, 12);
Font.drawText(7, 7, "Cold Foam");    
FlipScreen();
Delay(500);

Battle.stingamount = 1;

Battle.math = Math.random()/5 + .9;

  if (Player.attackmiss == "Miss")
  {
    RenderMap();
    TakeOutPlayerHealth();
  }
  else
  {
    RenderMap();
    Player.attackdamage = Math.floor(Battle.Mmag*Battle.math/Player.tempmag*3);
    TakeOutPlayerHealth();
    if (Player.PTarget == "Player1") 
    {
    Player.stun = Battle.stingamount;
    }
    if (Player.PTarget == "Player2") 
    {
    Player2.stun = Battle.stingamount;
    }
    if (Player.PTarget == "Player3") 
    {
    Player3.stun = Battle.stingamount;
    }
  }
  if (Player.dead == 3)
  {
  GarbageCollect();
  GameOver();
  }
  else
  {
  Player.attackmiss = "";
  GoToNextMonster();
  }
}

function SpecialSmack()
{
Player.attackmiss = "";
SelectPTarget();
RenderMap();
ShowPersonFight();
Delay(200);
RenderMap();
LoadDefStats();
DrawPlayerStats();
BattleName();
WindowStyle.drawWindow(5, 5, 235, 12);
Font.drawText(7, 7, "Smack");
FlipScreen();
Delay(500);

  if (Player.attackmiss == "Miss")
  {
    RenderMap();
    TakeOutPlayerHealth();
  }
  else
  {
    if (Player.templuck <= Battle.Mluck)
    {
      if (Math.random() <= 0.5)
      {
      RenderMap();
      Player.attackdamage = Math.floor(Player.temphp/2);
      TakeOutPlayerHealth();
      }
      else
      {
      Player.attackmiss = "Miss";
      RenderMap();
      TakeOutPlayerHealth();
      }
    }
    else
    {
      Player.attackmiss = "Miss";
      RenderMap();
      TakeOutPlayerHealth();
    }
  }
Player.attackmiss = "";
GoToNextMonster();
}




function ReduceMonsterMp(MmpReduce)
{
  if (Player.active == "Monster1")
  {
  Monster1.mp = Monster1.mp - MmpReduce;
  }
  else if (Player.active == "Monster2")
  {
  Monster2.mp = Monster2.mp - MmpReduce;
  }
  else if (Player.active == "Monster3")
  {
  Monster3.mp = Monster3.mp - MmpReduce;
  }
  else if (Player.active == "Monster4")
  {
  Monster4.mp = Monster4.mp - MmpReduce;
  }
}

function SetMonsterHp(MAmountHp)
{
  if (Player.active == "Monster1")
  {
  Monster1.hp = MAmountHp;
  }
  else if (Player.active == "Monster2")
  {
  Monster2.hp = MAmountHp;
  }
  else if (Player.active == "Monster3")
  {
  Monster3.hp = MAmountHp;
  }
  else
  {
  Monster4.hp = MAmountHp;
  }
}
